<template>
  <el-dialog
    title="申领客户"
    :visible.sync="dialogVisible"
    width="600px"
  >
    <el-form>
      <el-form-item label="申领类型:">
        <el-radio-group v-model="selectedType">
          <el-radio label="apply">申领客户</el-radio>
          <el-radio
            label="accurate"
            disabled
          >
            精准池客户申领
          </el-radio>
        </el-radio-group>
      </el-form-item>
    </el-form>
    <div
      slot="footer"
      class="dialog-footer"
    >
      <el-button @click="dialogVisible = false">取消</el-button>
      <el-button
        type="primary"
        :loading="submitting"
        @click="handleSave"
      >
        确定
      </el-button>
    </div>
  </el-dialog>
</template>

<script>
import { apiCustomerApply } from '@/api/clue'

export default {
  name: 'ApplyDialog',
  data() {
    return {
      dialogVisible: false,
      selectedType: 'apply',
      submitting: false
    }
  },
  methods: {
    // 打开弹窗
    openDialog() {
      this.dialogVisible = true
      this.selectedType = 'apply'
    },
    // 处理保存操作
    async handleSave() {
      this.submitting = true
      try {
        await apiCustomerApply()
        this.$message.success('申领成功')
        this.dialogVisible = false
        this.$emit('apply-success')
      } finally {
        this.submitting = false
      }
    }
  }
}
</script>

<style scoped></style>
